home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / comms / other / novia / bin / downloadselect.c < prev    next >
C/C++ Source or Header  |  1999-12-06  |  2KB  |  98 lines

  1. #include <pragma/noviasys_lib.h>
  2. #include <pragma/exec_lib.h>
  3. #include <pragma/dos_lib.h>
  4. #include <stdio.h>
  5. #include <novia/novia_portdata.h>
  6.  
  7. struct Library *NoviaSysBase;
  8.  
  9. void ioprintf(const char *string, ...)
  10. {
  11.     char *buffer=AllocVec(10000,MEMF_ANY|MEMF_CLEAR);
  12.     if (buffer)
  13.     {
  14.         vsprintf(buffer, string, unsigned int(&string + 1));
  15.         Writeio(buffer,-1);
  16.         FreeVec(buffer);
  17.     }
  18. }
  19.  
  20. void main()
  21. {
  22.     if ((NoviaSysBase = OpenLibrary("noviasys.library", 0)))
  23.     {
  24.         struct PortData *cport = (struct PortData *)FindTask(NULL)->tc_UserData;
  25.                 char quit = 0;
  26.                 struct Select *select=(Select *)cport->select_list.mlh_Head;
  27.                 while (quit<1 && select->ln_Succ)
  28.                 {
  29.                     ioprintf("download: (%s)%-40s ([Yes],No,All,Cancel,Quit) ? ",select->dirpath,select->filepath);
  30.                     switch (AskKey(RESULT_YES , FLAG_YES | FLAG_NO | FLAG_ALL | FLAG_CANCEL | FLAG_QUIT , 0))
  31.                     {
  32.                         case RESULT_YES:
  33.                             select->downloadnow=TRUE;
  34.                             break;
  35.                         case RESULT_NO:
  36.                             select->downloadnow=FALSE;
  37.                             break;
  38.                         case RESULT_ALL:
  39.                             while (select->ln_Succ)
  40.                             {
  41.                                 select->downloadnow=TRUE;
  42.                                 select=select->ln_Succ;
  43.                             }
  44.                             quit=1;
  45.                             break;
  46.                         case RESULT_CANCEL:
  47.                             while (select->ln_Succ)
  48.                             {
  49.                                 select->downloadnow=FALSE;
  50.                                 select=select->ln_Succ;
  51.                             }
  52.                             quit=1;
  53.                             break;
  54.                         case RESULT_QUIT:
  55.                             select=(Select *)cport->select_list.mlh_Head;
  56.                             while (select->ln_Succ)
  57.                             {
  58.                                 select->downloadnow=FALSE;
  59.                                 select=select->ln_Succ;
  60.                             }
  61.                             quit=2;
  62.                             break;
  63.                     }
  64.                     select=select->ln_Succ;
  65.                 }
  66.                 if (quit == 1)
  67.                 {
  68.                     ioprintf("do transfer\n");
  69.                     if (!IsListEmpty((List *)&cport->select_list))
  70.                     {
  71.                         struct SelectItem *select=(SelectItem *)cport->select_list.mlh_Head;
  72.                         char quit=FALSE;
  73.                         cport->actual = NULL;                            // reset actual download file
  74.                         while (select->ln_Succ && !quit)
  75.                         {
  76.                             if (select->downloadnow)
  77.                             {
  78.                                 cport->actual = select;                    // set first file to download
  79.                                 quit = TRUE;
  80.                             }
  81.                             select=select->ln_Succ;
  82.                         }
  83.                     }
  84.                     else
  85.                         ioprintf("no files to download\n");
  86.                 }
  87.                     
  88.                 if (IsListEmpty((List *)&cport->select_list))
  89.                     ioprintf("You have no no files selected\n");
  90.                 else
  91.                     DoTransfer();
  92.  
  93.             }
  94.             return TRUE;
  95.             break;
  96.         CloseLibrary(NoviaSysBase);
  97.     }
  98. }